package com.icode.core.dto.house;

import com.icode.core.model.house.MyHouse;
import com.icode.core.model.house.MyHouseStatus;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: xianfei
 * Date: 15-9-16
 * Time: 上午11:40
 * To change this template use File | Settings | File Templates.
 */
public class MyHouseDTO {
    private String guid;
    private HouseInfoDTO houseInfoDTO;
    private HouseWeekDTO houseWeekDTO;
    private String userInfoGuid;
    private String buyNum;
    private String exchangePoolStatus;
    private String usable;
    private String exchangeHouse;
    private RentDTO rentDTO;
    private String ownername;
    private String myHouseStatus;

    public MyHouseDTO() {
    }

    public MyHouseDTO(String guid, HouseInfoDTO houseInfoDTO, HouseWeekDTO houseWeekDTO, String userInfoGuid, String buyNum, String exchangePoolStatus, String usable, String exchangeHouse,String ownername,String myHouseStatus) {
        this.guid = guid;
        this.houseInfoDTO = houseInfoDTO;
        this.houseWeekDTO = houseWeekDTO;
        this.userInfoGuid = userInfoGuid;
        this.buyNum = buyNum;
        this.exchangePoolStatus = exchangePoolStatus;
        this.usable = usable;
        this.exchangeHouse = exchangeHouse;
        this.ownername = ownername;
        this.myHouseStatus = myHouseStatus;
    }

    public static MyHouseDTO toDTO(MyHouse myHouse) {
        HouseInfoDTO houseInfoDTO = HouseInfoDTO.toDTO(myHouse.houseInfo());
        HouseWeekDTO houseWeekDTO = HouseWeekDTO.toDTO(myHouse.houseWeek());
        String exchangePoolStatus = "";
        if (myHouse.myHouseStatus() != null) {
            exchangePoolStatus = myHouse.myHouseStatus().getValue();
        }
        String ownername = myHouse.userInfo().username();
        return new MyHouseDTO(myHouse.guid(), houseInfoDTO, houseWeekDTO, myHouse.userInfo().guid(), myHouse.buyNum(), exchangePoolStatus, String.valueOf(myHouse.usable()), String.valueOf(myHouse.exchangeHouse()),ownername,myHouse.myHouseStatus().getLabel());
    }

    public static List<MyHouseDTO> toDTOs(List<MyHouse> myHouses) {
        List<MyHouseDTO> myHouseDTOs = new ArrayList<>();
        for (MyHouse mh : myHouses) {
            myHouseDTOs.add(toDTO(mh));
        }
        return myHouseDTOs;
    }


    public String getGuid() {
        return guid;
    }

    public void setGuid(String guid) {
        this.guid = guid;
    }

    public HouseInfoDTO getHouseInfoDTO() {
        return houseInfoDTO;
    }

    public void setHouseInfoDTO(HouseInfoDTO houseInfoDTO) {
        this.houseInfoDTO = houseInfoDTO;
    }

    public HouseWeekDTO getHouseWeekDTO() {
        return houseWeekDTO;
    }

    public void setHouseWeekDTO(HouseWeekDTO houseWeekDTO) {
        this.houseWeekDTO = houseWeekDTO;
    }

    public String getUserInfoGuid() {
        return userInfoGuid;
    }

    public void setUserInfoGuid(String userInfoGuid) {
        this.userInfoGuid = userInfoGuid;
    }

    public String getBuyNum() {
        return buyNum;
    }

    public String getUsable() {
        return usable;
    }

    public void setUsable(String usable) {
        this.usable = usable;
    }

    public String getExchangeHouse() {
        return exchangeHouse;
    }

    public void setExchangeHouse(String exchangeHouse) {
        this.exchangeHouse = exchangeHouse;
    }

    public void setBuyNum(String buyNum) {
        this.buyNum = buyNum;
    }

    public String getExchangePoolStatus() {
        return exchangePoolStatus;
    }

    public void setExchangePoolStatus(String exchangePoolStatus) {
        this.exchangePoolStatus = exchangePoolStatus;
    }

    public String getOwnername() {
        return ownername;
    }

    public void setOwnername(String ownername) {
        this.ownername = ownername;
    }

    public String getMyHouseStatus() {
        return myHouseStatus;
    }

    public void setMyHouseStatus(String myHouseStatus) {
        this.myHouseStatus = myHouseStatus;
    }
}
